<template>
	<view class="page">
		<view class="weui-page__back">
			<image src="https://img.2024csnl.com/static/2.x/a38.png" mode="widthFix"></image>
		</view>
		<view class="page-head">
			<view class="money">
				<view class="label">
					<text>我的泌豆</text>
				</view>
				<view class="value">
					<image src="https://img.2024csnl.com/static/2.x/a39.png" mode=""></image>
					<text>{{ score || 0 }}</text>
				</view>
			</view>
			<view class="mo" @click="onSkip('/package/mine/myPoints/myPoints')">
				<text>泌豆明细</text>
				<image src="https://img.2024csnl.com/static/2.x/a40.png" mode=""></image>
			</view>
		</view>
		
		
		
		
		
		
		
		
		
		
		
		
		<!-- <view class="between flex-end integral-info">
			<view class="record" @click="onSkip('/pages/goods/integral-record')">兑换记录</view>
			<view class="">
				<view class="">泌豆余额</view>
				<view class="integral-num">{{score==null?0:score}}</view>
			</view>
			<view class="flex align" @click="onSkip('/package/mine/myPoints/myPoints')">
				<view class="detail">泌豆明细</view>
				<image src="https://wx.2024csnl.com/static/goods/into-white.png" mode="aspectFill" class="into" />
			</view>
		</view> -->
		
		<view class="page-body">
			<scroll-view
				scroll-x="true"
				class="scroll-box flex align">
				<view
					v-for="(nav,i) in navList"
					:key="i"
					:class="navIndex==nav.id?'nav-act':''"
					class="nav-item"
					@click="checkNav(nav.id)">
					<text>{{ nav.name}}</text>
					</view>
			</scroll-view>

			<view class="goods-list__x2">
				<view
					class="item"
					v-for="(v,i) in list"
					:key="i"
					@click="onSkip(`/pages/goods/integralDetails?id=${v.id}`)">
					<view class="cell">
						<view class="img">
							<image :src="v.pic" mode="aspectFill" />
						</view>
						<view class="info">
							<view class="name">
								<text>{{ v.name }}</text>
							</view>
							<view class="flex">
								<view class="price">
									<text>{{ v.score_price }}泌豆</text>
								</view>
								<view class="tag">
									<text>去兑换</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			
			<view
				class="flex-center addressImgBox"
				v-if="list.length==0">
				<image src="https://wx.2024csnl.com/static/noData.png"></image>
				暂无数据~
			</view>
		</view>
		
		<tabbar :current="2" :bid="1"></tabbar>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar.vue';
	import {
		setShoppingMall,
		getIntegrationClassify
	} from "../../api/index.js"
	export default {
		components: {
			tabbar,
		},
		data() {
			return {
				navIndex: null,
				navList: [],
				score: 0,
				id: '',
				list: [],

			}
		},
		onLoad(opt) {
			this.onGetIntegrationClassify()
		},
		methods: {
			// 分类
			async onGetIntegrationClassify() {
				const res = await getIntegrationClassify('s=ApiBusiness/jfspfl')
				const {
					data,
					status,
					msg
				} = res.data
				if (status == 1) {
					this.navList=data
					this.navIndex=data[0].id
					// console.log(res, "fff",this.navIndex)
						this.onSetShoppingMall()
				} else {
					this.showToast(msg)
				}
			},
			checkNav(id) {
				this.navIndex = id
				this.list=[]
				this.onSetShoppingMall()
			},
			async onSetShoppingMall() {
				const res = await setShoppingMall('s=/ApiBusiness/shjfshop', {
					cid: this.navIndex
				})
				const {
					status,
					jifen,
					dat,
					msg
				} = res.data
				if (status == 1) {
					this.list = dat
					this.score = jifen
					console.log(dat, "-----", )
					// console.log(JSON.parse(dat[0].guigedata))
				} else {
					this.showToast(msg)
				}
			},
		},

	}
</script>

<style>
	page {
		background-color: #F7F7F7;
	}
</style>

<style lang="scss" scoped>
	.addressImgBox {
		flex-direction: column;
		color: #999;
		padding-top: 20%;
	
		image {
			width: 400rpx;
			height: 400rpx;
		}
	}
	.scroll-box {
		width: 710rpx;
		margin: 30rpx;
		white-space: nowrap;
		font-size: 27rpx;
		color: #B3B3B3;

		.nav-item {
			display: inline-block;
			margin-right: 32rpx;
			min-width: 20%;
		}

		.nav-act {
			color: #41644A;
		}

		.nav-item:last-child {
			margin-right: 0;
		}
	}

	.record {
		position: absolute;
		top: 30rpx;
		right: 50rpx;
	}

	.integral-info {
		background-color: #82ECEF;
		color: #FFF;
		padding: 32rpx;
		font-size: 24rpx;

		.integral-num {
			font-size: 60rpx;
			font-weight: 500;
		}

		.detail {
			font-size: 27rpx;
			margin-bottom: 15rpx;
			margin-right: 15rpx;
		}

		image {
			margin-bottom: 15rpx;
		}
	}

	.goods-list {
		margin: 20rpx;
		flex-wrap: wrap;

		.goods-item {
			width: 343rpx;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			box-shadow: 0 1rpx 10rpx 0 rgba(0, 0, 0, 0.1);

			.goods-img {
				width: 343rpx;
				height: 280rpx;
				border-radius: 20rpx 20rpx 0 0;
			}

			.goods-info {
				padding: 20rpx;
				font-size: 27rpx;
			}

			.goods-price {
				font-size: 40rpx;
				color: #41644A;
			}

			.goods-tag {
				font-size: 20rpx;
				color: #FE8E06;
				display: inline-block;
				padding: 2rpx 12rpx;
				border: 1rpx solid #FE8E06;
				border-radius: 8rpx;
				margin-left: 16rpx;
			}
		}
	}
	
	.page {
		min-height: 100vh;
	}
	
	.page-head {
		display: flex;
		align-items: flex-end;
		padding: 80rpx 40rpx 40rpx;
		.money {
			flex: 1;
			.label {
				height: 60rpx;
				line-height: 60rpx;
				text {
					font-size: 28rpx;
					color: #ffffff;
					opacity: .8;
				}
			}
			.value {
				display: flex;
				align-items: center;
				line-height: 60rpx;
				image {
					display: block;
					width: 50rpx;
					height: 50rpx;
				}
				text {
					font-size: 60rpx;
					color: #ffffff;
					margin-left: 10rpx;
				}
			}
		}
		.mo {
			display: flex;
			align-items: center;
			line-height: 60rpx;
			image {
				display: block;
				width: 36rpx;
				height: 36rpx;
			}
			text {
				color: #ffffff;
				margin-right: 10rpx;
			}
		}
	}
	
	.page-body {
		background: #f8f8f8;
		border-radius: 20rpx 20rpx 0 0;
		.scroll-box {
			.nav-item {
				height: 100rpx;
				line-height: 100rpx;
				position: relative;
				&.nav-act {
					&:before {
						content: '';
						position: absolute;
						left: 0rpx;
						top: 60rpx;
						width: 140rpx;
						height: 16rpx;
						border-radius: 10rpx;
						background: -webkit-linear-gradient(left, #FDD69F, #ffffff);
					}
					text {
						position: relative;
						padding: 0 10rpx;
						font-size: 32rpx;
						font-weight: bold;
						z-index: 2;
					}
				}
				text {
					font-size: 28rpx;
					color: #000000;
				}
			}
		}
		.goods-list__x2 {
			display: flex;
			flex-wrap: wrap;
			padding: 0 10rpx;
			margin-top: -30rpx;
			.item {
				width: 50%;
			}
			.cell {
				margin: 10rpx;
				padding: 10rpx;
				background: #ffffff;
				border-radius: 10rpx;
			}
			.img {
				image {
					display: block;
					width: 100%;
					height: 300rpx;
					background: #eeeeee;
					border-radius: 10rpx;
				}
			}
			.info {
				position: relative;
				padding: 10rpx;
			}
			.name {
				height: 60rpx;
				line-height: 60rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				text {
					font-size: 28rpx;
				}
			}
			.flex {}
			.price {
				flex: 1;
				line-height: 60rpx;
				font-size: 30rpx;
				color: #E86A33;
			}
			.tag {
				height: 60rpx;
				line-height: 60rpx;
				border-radius: 60rpx;
				padding: 0 20rpx;
				background: -webkit-linear-gradient(left, #41644A, #263A29);
				text {
					font-size: 24rpx;
					color: #ffffff;
				}
			}
		}
	}
</style>
